#include "http.h"
using namespace std;

int main(int argc, char *argv[], char **envp) {
	if(!InitSocket()) return -1;
	MIMEMap mime;
	ServerList conf;
	MIMEParser pm;
	pm.Parse(&mime);
	MainParser pc;
	pc.Parse(&conf);
	cout<<"CPP-HTTPD Daemon v1.0 - by Gerald"<<endl;
	for(int i=0;i<conf.size();i++) {
		HTTPServer *s=new HTTPServer(conf[i]);
		s->pmime=&mime;
		if(i+1<conf.size())
			s->_StartServer();	// start a new thread
		else
			s->StartServer();	// start in current thread
	}
	return 0;
}
